﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace h2100
{
    /// <summary>
    /// Con trỏ chuột
    /// </summary>
    public class hCursor:hVisibleGameObject
    {
        public hCursor(ContentManager content)
        {
            String[] strPointer =
                { 
                    hGlobal.PathGui + "MousePointer", 
                    hGlobal.PathGui + "MousePointer2",
                    hGlobal.PathGui + "MousePointer3",
                    hGlobal.PathGui + "MousePointer2" 
                };
            base.create1SpriteObject(content, strPointer);           
        }

        public int nDelay = 20;
        protected int iDelay = 0;

        public override void update(hParams args, GameTime gameTime)
        {
            MouseState mouse = Mouse.GetState();
            X = mouse.X;
            Y = mouse.Y;

            if (iDelay == 0)
            {
                base.update(args, gameTime);
            }
            iDelay = (iDelay + 1) % nDelay;
        }

        public void draw(hParams args,GameTime gameTime, SpriteBatch spriteBatch )
        {
            if (args.SubCursor != null && args.IsMouseOverMap)
            {
                spriteBatch.Draw(args.SubCursor, new Vector2(X - args.SubCursor.Width / 2, Y - args.SubCursor.Height / 2), args.SubCursorColor);
            }
            base.draw(gameTime, spriteBatch);
        }
    }
}
